import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Shapes 1.15
import QtQuick.Layouts 1.15

MainView {
    id: root
    width: 800
    height: 391
    property color btnColor: "#7080C0"
    property int btnHeight: 50
    property int btnWidth: 125
    signal startLoad
    function getWeightText(no){
        switch(no){
            case 0:
                return mymodbus.voltage0;
            case 1:
                return mymodbus.voltage1;
            case 2:
                return mymodbus.voltage2;
            case 3:
                return mymodbus.voltage3;
            case 4:
                return mymodbus.voltage4;
            case 5:
                return mymodbus.voltage5;
            case 6:
                return mymodbus.voltage6;
            case 7:
                return mymodbus.voltage7;
        }
    }
    onStartLoad: {

    }
    Component.onCompleted: {
        startLoad()

    }
    Component.onDestruction: {
        debugTimer.repeat = false
        debugTimer.running = false
    }
    DeviceCardGrid
       {
           id:deviceCardGrid
           x:0
           y:70
           width: 800
           height: 200
       }

        Button
        {
            id:btnReturn
            x: 688
            y: 281
            //x: 675
            //y: 20
            width: 100
            height: 100
            background: Rectangle{
                border.width: 0
                color: "#B0B0D0"
                    }

            text: qsTr("返回")
            font.pixelSize: 25
            palette.buttonText: "white"
            Connections {
                target: btnReturn
                onClicked: {
                    //rectangle.selectedView = 2
                    bottomBar.selected=2
//                    myLoader.visible =false;
//                    myLoader.visible =true
                    myLoader.source="FunctionPanel.qml"
                }
            }
        }
        MyBuzyIndicator{
            anchors.centerIn: parent
            id: zeroCalLoader
            visible:false
        }
        Dialog {
            anchors.centerIn: parent
            closePolicy: "CloseOnEscape"
            modal:true
            id: zeroCalPanelDialog
            standardButtons: Dialog.Ok
            onAccepted: {
                zeroCalPanelDialog.close()
                if(zeroCalOK){
                    bottomBar.selected=0
//                    myLoader.visible=false;
//                    myLoader.visible=true;
                    myLoader.source="StatusView.qml"
                    //statusView.visible=true;
                }
            }
            z:100
        }
        Timer{
            id: debugTimer
            running: true
            repeat: true
            interval: mymodbus.collectTime
            onTriggered: {
                //mymodbus.getCollectData0(deviceIndex.currentIndex)
                //weight.text = qsTr("重量:")+getWeightText(deviceIndex.currentIndex)+mymodbus.unit
                //voltage.text= qsTr("电压:")+mymodbus.voltage(deviceIndex.currentIndex).toString()+"mV"
            }
        }
}

